import type { ComponentPublicInstance, VueElement } from 'vue'

interface RuleEventOptions {
    type: string,
    field: string,
    props: any,
    codes: any,
    style?: any,
    Event?: any,
    validate?: any,
}

interface Group {
    type: string,
    props: {
        title: string
    },
    children: PropEventOptions
}


interface Action {
    type: string,
    props: {
        EventList: Array<RunEventOption>
    }
}

type PropEventOption = 'Field' | 'Title' | Group | Action | any;
type PropEventOptions = Array<PropEventOption>;

interface RunEventOption {
    label: string,
    value: string,
}
type RunEventOptions = Array<RunEventOption>;

interface LinkageEventOption {
    title: string,
    children: Array<PropEventOption>
}
type LinkageEventOptions = Array<LinkageEventOption>;


type RuleEvent = () => RuleEventOptions;
type PropEvent = () => PropEventOptions;
type RunEvent = () => RunEventOptions;
type LinkageEvent = (Rule: RuleOptions, Cell: ComponentPublicInstance) => LinkageEventOptions;


interface RuleOptions {

    /**
     * 图标
     *
     * @type {string}
     * @memberof RuleOptions
     */
    icon: string,
    /**
     * 名称
     *
     * @type {string}
     * @memberof RuleOptions
     */
    name: string,

    /**
     * 原件类型
     *
     * @type {string}
     * @memberof RuleOptions
     */
    type: string,

    /**
     * 原件编辑器 右上角工具栏
     *
     * @type {{
     *         Delete?: boolean,
     *         Copy?: boolean,
     *         Hide?: boolean,
     *     }}
     * @memberof RuleOptions
     */
    Tools?: {

        /**
         * 是否可删除
         *
         * @type {boolean}
         */
        Delete?: boolean,
        /**
         * 是否可复制
         *
         * @type {boolean}
         */
        Copy?: boolean,
        /**
         * 是否可隐藏
         *
         * @type {boolean}
         */
        Hide?: boolean,
    },
    DragType: string,
    rule: RuleEvent,
    props: PropEvent,
    RunEvent?: RunEvent,
    LinkageEvent?: LinkageEvent
}


function defaultRuleOptions(data: RuleOptions) {
    return data
}

export { defaultRuleOptions }